Datenstrom in Baumstruktur anzeigen

Dieses Programm ist ein besonderes Schmankerl! Hiermit können Sie einen RDI-Datenstrom in einer Baumstruktur anzeigen lassen. Die einzelnen Fenster und Elemente werden als eigene Äste dargestellt. Jeden Ast können Sie aufklappen und die Variablen sehen.Für besonders “wichtige” Variablen (NAST, SYST, …) können separate Icons verwendet werden.

 


Selektion der Spoolaufträge


Die gefundenen Spoolaufträge


So werden die RDI-Daten angezeigt


Inkludierte Texte werden als Einheit dargestellt

Der Report

REPORT zrdi_baum MESSAGE-ID tree_control_msg LINE-SIZE  230.

***********************************************************************
***  Programm zum Anzeigen eines RDI-Datenstroms in Form einer      ***
***  Baumstruktur.                                                  ***
***                                                                 ***
***  Features:                                                      ***
***  – Selektion nach Benutzer, Datum und Titel des Spoolauftrags   ***
***  – Anzeige von RDI-Spoolaufträgen                               ***
***  – Aktualisieren der Liste                                      ***
***  – Verwendung des TreeControls                                  ***
***  – Anzeige von Inkludiertem Text                                ***
***  – Eigene Icons für die bestimmte Variablenstrukturen (NAST,    ***
***    SYST, oder andere)                                           ***
***                                                                 ***
***  Anpassungen:                                                   ***
***  – PF-Status ‘MAIN’                                             ***
***    Ok-Codes: “BACK” für F3,SHift-F3, ESC                        ***
***  – PF-Status ‘LISTE’                                            ***
***    Ok-Codes: “PICK” zur Zeilenauswahl                           ***
***              “REFRESH” zum Aktualisieren                        ***
***  – Dynpro 100                                                   ***
***    CustomControl RDITREE über die gesamte Dynprogröße einfügen  ***
***    Ablauflogik:                                                 ***
***    PROCESS BEFORE OUTPUT.                                       ***
***      MODULE pbo_0100.                                           ***
***    PROCESS AFTER INPUT.                                         ***
***      MODULE USER_COMMAND_0100.                                  ***
***                                                                 ***
***********************************************************************
***                                                                 ***
***                                                                 ***
***                   http/www.tricktresor.com                       ***
***                                                                 ***
***                                                                 ***
***********************************************************************

TYPE-POOLS icon.

CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw      DEFINITION LOAD.

TYPES: node_table_type LIKE STANDARD TABLE OF mtreesnode
                       WITH DEFAULT KEY.

TYPES: item_table_type LIKE STANDARD TABLE OF mtreeitm
                       WITH DEFAULT KEY.

CONSTANTS:
  k_folder     VALUE ‘X’,
  k_no_folder  VALUE space,
  v            VALUE ‘|’.

DATA:
  l_rq       LIKE tsp01sys,
  l_handle   LIKE sy-tabix,
  l_spoolid  LIKE tsp01-rqident,
  t_lines    LIKE rspo_ds    OCCURS 0 WITH HEADER LINE,
  t_pages    LIKE rspo_index OCCURS 0 WITH HEADER LINE,
  BEGIN OF tbuffer OCCURS 0,
    x(6),
    line(1000),
  END OF tbuffer,
  t_tsp01    LIKE tsp01sys   OCCURS 0 WITH HEADER LINE,
  l_tsp01    LIKE tsp01,

  BEGIN OF l_txtinc,
    system(10),
    name(70),
    object(4),
    id(4),
    spras(3),
  END OF l_txtinc,
  l_text(72),

  xnode(12),
  znode(12),
  xitem      TYPE tv_nodekey,
  root_type(12),
  root_type_alt(12),
  root_spool(12),
  merk_type,
  merk_rdi_text,
  merk_element(40),
  merker_text_start,
  xicon      TYPE tv_image,
  datum      LIKE sy-datum,
  zeit       LIKE sy-uzeit,

  g_event(30),
  g_node_key TYPE tv_nodekey,

  g_application      TYPE REF TO lcl_application,
  g_custom_container TYPE REF TO cl_gui_custom_container,
  g_tree             TYPE REF TO cl_gui_column_tree,
  g_ok_code  TYPE sy-ucomm,

  merker_textcontrol,
  merk_spoolid(3) TYPE n,

  node_table TYPE treev_ntab,
  item_table TYPE item_table_type,

  node       LIKE mtreesnode,
  item       TYPE mtreeitm,
  l_node_image LIKE node-n_image,


*– Generelle Struktur
  BEGIN OF struc,
    type,     “H=HEADER D=DATA S=???? C=CONTROL
    line(3000),
  END OF struc,

*– DATA
  BEGIN OF struc_data,
    BEGIN OF element,
      fenster(8),
      start,
      neu,
      element(30),
    END OF element,
    variable(131),
    len(3) TYPE n,
    wert(500),
  END OF struc_data,

*– HEADER
  BEGIN OF struc_header,
    version(4),
    mandt(3),
    char1,
    spoolid(11),
    spras,
    formname(16),
    geraet(10),
    leer1(65),
    charx,
    leer2(59),
    zahl,
    drucker(4),
    geraet2(12),                                            “SAPGOF
    suff1(6),
    suff2(4),
    suff3(12),
    charx2,
    leer3,
    zahl2,
    leer4(100),
  END OF struc_header,

*– CONTROL
  BEGIN OF struc_control,
    command(300),
  END OF struc_control.

*———————————————————————*
*       CLASS LCL_APPLICATION DEFINITION
*———————————————————————*

CLASS lcl_application DEFINITION.

ENDCLASS.

*———————————————————————*
*       CLASS LCL_APPLICATION IMPLEMENTATION
*———————————————————————*

CLASS lcl_application IMPLEMENTATION.

ENDCLASS.


*– Selektionsbild
SELECT-OPTIONS:
  s_rqown  FOR t_tsp01-rqowner DEFAULT sy-uname,
  s_datum  FOR sy-datum        DEFAULT sy-datum TO sy-datum,
  s_rqtitl FOR t_tsp01-rqtitle.
PARAMETERS:
  p_last AS CHECKBOX DEFAULT ‘X’.


*– Start
START-OF-SELECTION.

  PERFORM spoolauftraege_selektieren.

*– PF-Code in der Liste
AT USER-COMMAND.
  CASE g_ok_code.
    WHEN ‘REFRESH’.
      PERFORM spoolauftraege_selektieren.

  ENDCASE.

*– Doppelklick in der Liste
AT LINE-SELECTION.

*– Lesen des Spoolauftrags
*– FB RSPO_RETURN_SPOOLJOB funktioniert leider nicht, da die übergebene
*– Tabelle nur 255 Zeichen lang ist. Wenn inkludierter Text dabei ist,
*– dann muss die Tabelle jedoch bis zu 1000 Zeichen breit sein!
  REFRESH tbuffer.
  l_tsp01 = t_tsp01.
  PERFORM read_data IN PROGRAM saplspox
   TABLES tbuffer
    USING l_tsp01 1 0.

  IF NOT tbuffer[] IS INITIAL.
    CREATE OBJECT g_application.
    CALL SCREEN 100.
  ENDIF.

*&———————————————————————*
*&      Form  CREATE_AND_INIT_TREE
*&———————————————————————*

FORM create_and_init_tree.

  DATA: event TYPE cntl_simple_event,
        events TYPE cntl_simple_events,
        hierarchy_header TYPE treev_hhdr.

  CLEAR: node_table, item_table.

* create a container for the tree control
  CREATE OBJECT g_custom_container
    EXPORTING
      container_name              = ‘RDITREE’.

  hierarchy_header-heading = ‘Spoolaufträge’.               “#EC NOTEXT
  hierarchy_header-width   = 60.

* create a tree control
  CREATE OBJECT g_tree
    EXPORTING
      parent                      = g_custom_container
      node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
      item_selection              = ‘X’
      hierarchy_column_name       = ‘Column1’
      hierarchy_header            = hierarchy_header.

* Column 2
  CALL METHOD g_tree->add_column
    EXPORTING
      name                          = ‘Column2’
      width                         = 6
      header_text                   = ‘Len’.

* Column3
  CALL METHOD g_tree->add_column
    EXPORTING
      name                          = ‘Column3’
      width                         = 90
      alignment = cl_gui_column_tree=>align_left
      header_text                   = ‘Wert’
      header_image                  = xicon.

* Aufbau des Baumes
  PERFORM build_node_table.

* Daten an TreeControl schicken
  CALL METHOD g_tree->add_nodes_and_items
    EXPORTING
      node_table                     = node_table
      item_table                     = item_table
      item_table_structure_name      = ‘MTREEITM’.

* expand the node with key ‘Root’
  CALL METHOD g_tree->expand_node
    EXPORTING
     node_key             = ‘Root’.

* 1. Stufe Expandieren
  CALL METHOD g_tree->expand_node
    EXPORTING
     node_key             = ‘          1 ‘.

* HeaderData Expandieren
  CALL METHOD g_tree->expand_node
    EXPORTING
     node_key             = ‘          2 ‘.

ENDFORM.                    ” CREATE_AND_INIT_TREE

*&———————————————————————*
*&      Form  BUILD_NODE_TABLE
*&———————————————————————*

FORM build_node_table.

* Node with key ‘Root’
  CLEAR node.
  node-node_key  = ‘Root’.
  node-isfolder  = ‘X’.
  node-expander  = ‘X’.
  node-text      = t_tsp01-rqident.
  APPEND node TO node_table.

  CLEAR item.
  item-node_key  = ‘Root’.
  item-item_name = ‘Column1’.
  item-class     = cl_gui_column_tree=>item_class_text.     ” Text Item
  item-text      = ‘Liste’.
  APPEND item TO item_table.

  xnode = 1.

  LOOP AT tbuffer.
    struc = tbuffer-line.
    CLEAR merker_text_start.

    CASE struc-type.
      WHEN ‘D’.
        struc_data = struc-line.
        IF merk_rdi_text = space.
          CHECK struc_data-variable <> space.
        ENDIF.
        CLEAR struc_data-element-start.
        CLEAR struc_data-element-neu.
      WHEN ‘H’.
        struc_header = struc-line.
      WHEN ‘S’.
        CONTINUE.
      WHEN ‘C’.
        struc_control = struc-line.
    ENDCASE.


    IF merk_type <> struc-type OR
            ( merk_element <> struc_data-element
          AND struc_data-element <> space ).
      root_type_alt = root_type.
      root_type = xnode.
      CLEAR node.
      CASE struc-type.
        WHEN ‘D’.
          IF merk_rdi_text = space.
            CHECK struc_data-variable <> space.
          ENDIF.
          IF  merk_rdi_text = ‘X’.
            merk_element = struc_data-element.
            SUBTRACT 2 FROM root_type.
          ELSE.
            merk_element = struc_data-element.

            PERFORM add_node USING xnode root_spool k_folder
                                   space.
            IF struc_data-element = space.
              struc_data-element = ‘…’.
            ENDIF.
            PERFORM add_item USING node-node_key ‘1’ struc_data-element.
          ENDIF.
        WHEN ‘H’.
          ADD 1 TO merk_spoolid.

          PERFORM add_node USING xnode ‘Root’ k_folder
                  icon_spool_request.
          PERFORM add_item USING xnode ‘1’ ‘Spoolauftrag’.
          PERFORM add_item USING xnode ‘2’ merk_spoolid.
          CLEAR item.
          item-node_key = xnode.
          item-item_name = ‘Column3’.
          item-class = cl_gui_column_tree=>item_class_text.
          CONCATENATE struc_header-suff1
                      struc_header-suff2
                      struc_header-suff3
                 INTO item-text SEPARATED BY space.
          APPEND item TO item_table.
          root_spool = xnode.

          ADD 1 TO xnode.

          PERFORM add_node USING xnode root_spool k_folder icon_header.
          PERFORM add_item USING node-node_key ‘1’ ‘Headerdata’.
          znode = xnode.
          PERFORM add_nodeitem
            USING znode ‘Spoolauftrag’ space
                  struc_header-spoolid.
          PERFORM add_nodeitem
            USING znode ‘Formular’ space struc_header-formname.
          PERFORM add_nodeitem
            USING znode ‘Drucker’ space struc_header-drucker.
        WHEN ‘C’.
          merker_textcontrol = ‘X’.
          IF struc_control CS ‘RDI-CONTROL %%LINES-END’ OR
             struc_control(7) = ‘INC-END’.
            root_type     = root_type_alt.
            merk_type     = struc-type.
            merk_rdi_text = space.
            CONTINUE.

          ELSEIF struc_control CS ‘RDI-CONTROL %%LINES-BEGIN’ OR
                 struc_control(9) = ‘INC-BEGIN’.
            merk_element = ‘RDI-Text’.
            merk_rdi_text = ‘X’.
            PERFORM add_node USING xnode root_spool k_folder
                                   icon_customer_master_data_list.
            PERFORM add_item USING node-node_key ‘1’ merk_element.

            CLEAR l_txtinc.
            SPLIT struc-line AT space
             INTO l_txtinc-system
                  l_txtinc-name
                  l_txtinc-object
                  l_txtinc-id
                  l_txtinc-spras.
            IF NOT l_txtinc IS INITIAL.
              CONCATENATE
                    ‘Name:’    l_txtinc-name
                    ‘Objekt:’  l_txtinc-object
                    ‘ID:’      l_txtinc-id
                    ‘Sprache:’ l_txtinc-spras
                INTO l_text SEPARATED BY space.
              PERFORM add_item USING node-node_key ‘2’ space.
              PERFORM add_item USING node-node_key ‘3’ l_text.
            ENDIF.
          ELSE.
            merker_textcontrol = space.
            PERFORM add_node USING xnode root_spool k_folder
                                   icon_draw_angular.
            PERFORM add_item USING node-node_key ‘1’ ‘Control’.
          ENDIF.
        WHEN ‘S’.
          CONTINUE.
      ENDCASE.

      ADD 1 TO xnode.
      merk_type = struc-type.
    ENDIF.


    CASE struc-type.
      WHEN ‘D’.
        CHECK merker_text_start = space.
*__________________________________________________________________*
*
* Hier können Icons für Felder angegeben werden, die im Datenstrom
* besonders hervorstechen sollen
*__________________________________________________________________*
*
        IF struc_data-variable(3) = ‘SY-‘.
          node-n_image   = icon_database_table.
        ELSEIF struc_data-variable(5) = ‘NAST-‘.
          node-n_image   = icon_msg.
        ELSEIF struc_data-variable(6) = ‘L_RKO-‘.
          node-n_image   = icon_header.
        ELSEIF struc_data-variable(10) = ‘KONDITION-‘.
          node-n_image   = icon_price.
        ELSEIF struc_data-variable(1) = ‘$’.
          node-n_image   = icon_variable.
        ELSEIF merk_rdi_text = ‘X’.
          node-n_image   = icon_text_field.
        ENDIF.
        l_node_image = node-n_image.
        DO.
          PERFORM add_node
            USING xnode root_type k_no_folder l_node_image.
          PERFORM add_item USING node-node_key ‘1’ struc_data-variable.
          PERFORM add_item USING node-node_key ‘2’ struc_data-len.
          PERFORM add_item USING node-node_key ‘3’ struc_data-wert(72).
          SHIFT struc_data-wert BY 72 PLACES LEFT.
          IF struc_data-wert(72) = space.
            EXIT.
          ELSE.
*– Folgezeilen, falls der Text/ Variable zu lang ist (> 72 Zeichen)
            ADD 1 TO xnode.
            l_node_image = icon_space.
            CLEAR struc_data-len.
          ENDIF.
        ENDDO.
      WHEN ‘H’.
        CONTINUE.
      WHEN ‘C’.
        CLEAR node.
        IF merker_textcontrol = space.
          PERFORM add_node
            USING xnode root_type k_no_folder space.
          PERFORM add_item
            USING node-node_key ‘1’ struc_control-command.
        ELSEIF merk_rdi_text = ‘X’.
          merk_type = ‘D’.
        ELSE.
          merk_type = ‘D’.
        ENDIF.

    ENDCASE.

    ADD 1 TO xnode.

  ENDLOOP.

ENDFORM.                    ” BUILD_NODE_TABLE

*&———————————————————————*
*&      Module  pbo_0100  OUTPUT
*&———————————————————————*

MODULE pbo_0100 OUTPUT.

  SET PF-STATUS ‘MAIN’.
  IF g_tree IS INITIAL.
    ” The Tree Control has not been created yet.
    ” Create a Tree Control and insert nodes into it.
    PERFORM create_and_init_tree.
  ENDIF.

ENDMODULE.                 ” pbo_0100  OUTPUT

*&———————————————————————*
*&      Module  USER_COMMAND_0100  INPUT
*&———————————————————————*

MODULE user_command_0100 INPUT.

  DATA: return_code TYPE i.

  CASE g_ok_code.
    WHEN ‘BACK’.
      CALL METHOD cl_gui_cfw=>dispatch
        IMPORTING return_code = return_code.
      IF return_code <> cl_gui_cfw=>rc_noevent.
        ” a control event occured => exit PAI
        CLEAR g_ok_code.
        EXIT.
      ENDIF.

      CALL METHOD g_tree->free.
      CALL METHOD g_custom_container->free.
      CLEAR g_tree.
      CLEAR g_custom_container.

      SET SCREEN 0. LEAVE SCREEN.
  ENDCASE.
ENDMODULE.                 ” USER_COMMAND_0100  INPUT

*&———————————————————————*
*&      Form  add_item
*&———————————————————————*

FORM add_nodeitem USING value(nkey)
                        value(col1)
                        value(col2)
                        value(col3).

  ADD 1 TO xnode.
  CLEAR node.
  node-node_key  = xnode.
  node-relatkey  = nkey.
  node-relatship = cl_gui_column_tree=>relat_last_child.
  APPEND node TO node_table.

  CLEAR item.
  item-node_key  = xnode.
  item-item_name = ‘Column1’.
  item-class     = cl_gui_column_tree=>item_class_text.
  item-text      = col1.
  APPEND item TO item_table.

  CLEAR item.
  item-node_key  = xnode.
  item-item_name = ‘Column2’.
  item-class     = cl_gui_column_tree=>item_class_text.
  item-text      = col2.
  APPEND item TO item_table.

  CLEAR item.
  item-node_key  = xnode.
  item-item_name = ‘Column3’.
  item-class     = cl_gui_column_tree=>item_class_text.
  item-text      = col3.
  APPEND item TO item_table.

ENDFORM.                    ” add_nodeitem

*———————————————————————*
*       FORM add_item                                                 *
*———————————————————————*

FORM add_item USING value(f_node)
                    value(f_col)
                    value(f_text).

  CLEAR item.
  item-node_key  = f_node.
  CONCATENATE ‘Column’ f_col INTO item-item_name.
  item-class     = cl_gui_column_tree=>item_class_text.
  item-text      = f_text.
  APPEND item TO item_table.

ENDFORM.

*&———————————————————————*
*&      Form  add_node
*&———————————————————————*

FORM add_node USING value(f_node)
                    value(f_relat)
                    value(f_folder)
                    value(f_img).

  CLEAR node.
  node-node_key  = f_node.
  node-relatkey  = f_relat.
  node-relatship = cl_gui_column_tree=>relat_last_child.
  node-isfolder  = f_folder.
  node-expander  = f_folder.
  node-n_image   = f_img.
  node-exp_image = f_img.
  APPEND node TO node_table.

ENDFORM.                                                    ” add_node

*&———————————————————————*
*&      Form  spoolauftraege_selektieren
*&———————————————————————*

FORM spoolauftraege_selektieren.

  sy-lsind = 1.

  SET PF-STATUS ‘LISTE’.

  CALL FUNCTION ‘RSPO_ISELECT_SPOOLREQS’
       EXPORTING
            rfcsystem    = ‘NONE’
       TABLES
            s_rqowne     = s_rqown
            s_rqcred     = s_datum
            s_rqtitl     = s_rqtitl
            result_tsp01 = t_tsp01
       EXCEPTIONS
            error        = 1
            OTHERS       = 2.

  CHECK sy-subrc = 0.

  LOOP AT t_tsp01 WHERE rqdoctype = ‘RDI’.
    WRITE: /
          t_tsp01-rqident,
          t_tsp01-rq0name,
          t_tsp01-rq1name,
          t_tsp01-rq2name,
          t_tsp01-rqtitle,
          t_tsp01-rqowner,
          t_tsp01-rqdest.
    HIDE t_tsp01.
  ENDLOOP.
  CLEAR t_tsp01.

  IF p_last = ‘X’.
    CLEAR p_last.
    SET CURSOR LINE 3.
    SET USER-COMMAND ‘PICK’.
  ENDIF.

ENDFORM.                    ” spoolauftraege_selektieren

 

Enno Wulff
Letzte Artikel von Enno Wulff (Alle anzeigen)

Leave a Comment